/**
 * Copyright © 2014 Winit Corp. All rights reserved.
 * This software is proprietary to and embodies the confidential
 * technology of Winit Corp.  Possession, use, or copying
 * of this software and media is authorized only pursuant to a
 * valid written license from Winit Corp or an authorized sublicensor.
 */
package com.winit.openapi.ups.controller;

import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.constants.ErrorCode;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.exception.ApiException;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ums.spi.UmsCustomerService;
import com.winit.ums.spi.commnad.customer.QueryCompanylCommand;
import com.winit.ums.spi.vo.CustomerInfoVO;
import com.winit.ups.spi.command.CodeCommand;
import com.winit.ups.spi.warehouse.WarehouseBlacklistService;
import com.winit.ups.spi.warehouse.vo.PageWarehouseBlacklistVo;

/**
 * 卖家仓库限制
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * qianyun.yang_guest 	1.0  		2017年1月10日 	Created
 *
 * </pre>
 * @since 1.
 */
@Controller
@RequestMapping(value = "/ups")
public class UpsWarehouBlacklistController extends BaseController{
    
    private Logger  logger = LoggerFactory.getLogger(UpsWarehouBlacklistController.class);
    
    @Resource
    private WarehouseBlacklistService warehouseBlacklistService;
    
    /**
     * ums客户信息
     */
    @Resource
    private UmsCustomerService umsCustomerService;
    
    @RequestMapping(value = "/queryWarehouseBlacklistByCustomerCode")
    public String queryWarehouseBlacklistByCustomerCode(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
        QueryCompanylCommand queryCompanylCommand = new QueryCompanylCommand();
        queryCompanylCommand.setEmail(CommandContext.getContext().getUsername());
        CustomerInfoVO customerInfoVO = umsCustomerService.queryCompanyByUserName(queryCompanylCommand);
        if (customerInfoVO == null) {
            throw new ApiException(ErrorCode.USER_NOT_FOUND);
        }
        CodeCommand command = new CodeCommand();
        command.setCode(customerInfoVO.getCode());
        List<PageWarehouseBlacklistVo> vos = warehouseBlacklistService.queryWarehouseBlackListByCustomerCode(command);
        responseMsg.setData(vos);
        return SUCCESS;
    }
    
    

}
